import request from "@/utils/request";
import {BaseResponse} from "@/api/types/baseResponse";
import SalaryGroupResponse from "@/api/types/salaryGroup/SalaryGroupResponse";

// 获取所有薪资组
export async function getSalaryGroups() {
    return await request<
        BaseResponse<{ info_list?: SalaryGroupResponse[] }>,
        BaseResponse<{ info_list?: SalaryGroupResponse[] }>
    >({
        url: "/salary/salarygroup"
    })
}

// 增加薪资组
export async function addSalaryGroup(salaryGroup: SalaryGroupRequest) {
    return await request<BaseResponse<{}>, BaseResponse<{}>>({
        url: "/salary/salarygroup",
        method: "POST",
        data: salaryGroup
    })
}

// 修改薪资组
export async function updateSalaryGroup(salaryGroup: SalaryGroupRequest) {
    return await request<BaseResponse<undefined>, BaseResponse<undefined>>({
        url: "/salary/salarygroup",
        method: "PUT",
        data: salaryGroup
    })
}

// 根据ID删除薪资组
export async function deleteSalaryGroupById(id: number) {
    return await request<BaseResponse<boolean>, BaseResponse<boolean>>({
        url: "/salary/salarygroup",
        method: "DELETE",
        data: {salarygroup_id: id}
    })
}
